/**
 * 系统设置
 * @author 许明浩 微信: muaiyuese
 */
import type { SystemInfo } from "./types/system-info";
/**
 * constants
 */
const actionPrefix = `SystemInfo/`;
export const TOGGLE_CHOOSEAVATARUSER = actionPrefix + "TOGGLE_CHOOSEAVATARUSER";

/**
 * actions
 */
/**
 * 开启授权用户信息弹窗
 * @param {}
 * @return
 */
export const toggleChooseAvatarUser = (visibleChooseAvatarUser) => {
  if (process.env.TARO_ENV !== "weapp") {
    return {
      type: TOGGLE_CHOOSEAVATARUSER,
      visibleChooseAvatarUser: false,
    };
  }
  return {
    type: TOGGLE_CHOOSEAVATARUSER,
    visibleChooseAvatarUser,
  };
};

/**
 * state
 */
const INITIAL_STATE: SystemInfo = {
  /**
   * 显示隐藏授权用户信息弹窗
   */
  visibleChooseAvatarUser: false,
};
export default function user(state = INITIAL_STATE, action) {
  switch (action.type) {
    case TOGGLE_CHOOSEAVATARUSER:
      return {
        ...state,
        visibleChooseAvatarUser: action.visibleChooseAvatarUser,
      };
    default:
      return state;
  }
}
